<!-- 当前列的所有档案或者档案盒 -->
<template>
  <div class="container">
    <!-- 单选切换 -->
    <el-radio-group v-model="amsType" style="margin-bottom: 10px">
      <el-radio-button label="1">盒</el-radio-button>
      <el-radio-button label="0">档案</el-radio-button>
    </el-radio-group>

    <!-- 搜索区域 -->
    <el-form :inline="true" :model="formInline" class="demo-form-inline" size="mini">
      <el-form-item :label="amsType == '1' ? '盒号/题名' : '档号/题名'">
        <el-input
          :placeholder="amsType == '1' ? '请输入盒号/题名' : '请输入档号/题名'"
          v-model="formInline.NoOrName"
          clearable
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="search">查询</el-button>
      </el-form-item>
    </el-form>
    <!-- 表格部分 -->
    <el-table :data="tableData" height="35vh" border style="width: 100%">
      <el-table-column prop="boxName" :label="amsType == '1' ? '盒名' : '档名'">
        <template slot-scope="{ row }">
          {{ amsType == '1' ? row.boxName : row.archiveName }}
        </template>
      </el-table-column>
      <el-table-column prop="boxNo" :label="amsType == '1' ? '盒号' : '档号'" width="180">
        <template slot-scope="{ row }">
          {{ amsType == '1' ? row.boxNo : row.archiveNo }}
        </template>
      </el-table-column>
      <el-table-column prop="positionId_dictText" label="库位"> </el-table-column>
    </el-table>
  </div>
</template>

<script>
import { archivesMovePage, boxOutPage } from '@/api/rfid/label.js'
export default {
  name: 'colAmsTable',
  components: {},
  data() {
    return {
      amsType: '1',
      tableData: [],
      formInline: {
        NoOrName: '',
      },
    }
  },
  computed: {},
  watch: {
    amsType(newVal) {
      this.getTableData()
      this.formInline.NoOrName = ''
    },
  },
  created() {},
  mounted() {
    this.getTableData()
  },
  methods: {
    search() {
      let params = {}
      if (this.amsType == '1') {
        params.boxNoOrName = this.formInline.NoOrName
      } else {
        params.archiveNoOrName = this.formInline.NoOrName
      }
      this.getTableData(params)
    },
    // 查询档案或者档案盒
    getTableData(params) {
      let apiUrl

      if (this.amsType == '1') {
        apiUrl = boxOutPage(params)
      } else {
        apiUrl = archivesMovePage(params)
      }
      apiUrl
        .then((res) => {
          if (res.data.code == 200) {
            this.tableData = res.data.data.records
          }
        })
        .catch((err) => {
          this.$message.error(err)
        })
    },
  },
}
</script>
<style lang="less" scoped></style>
